﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AcademicPlanForm.ascx.cs" Inherits="AcademicPlanner.Presentation.Views.Shared.AcademicPlanForm" %>
<%@ Import Namespace="AcademicPlanner.Framework.Helpers" %>
<%@ Import Namespace="AcademicPlanner.Presentation" %>
<%@ Import Namespace="AcademicPlanner.Domain.Models" %>

<% if (!Model.IsSub)
   { %>
		<div class="form acdemic-plan-form yui-skin-sam">
		<% Begin(); %>
<% } %>

<% if (!string.IsNullOrEmpty(Title))
   { %>
		<fieldset><legend><%= Html.Encode(Title) %></legend>
<% } %>

<% if (!Model.IsSub)
   { %>
		<%= WidgetHelper.FormErrorsBlock("", Model.Id + "Errors", "hidden") %>
<% } %>


<div class="rows-wrapper">
	<div class="row">
		<div class="cell label">
			<%= Html.Label(GetFieldName("CreditUnits"),
											Html.Encode(Tr(Labels.Get("CreditUnits", "AcademicPlan"))), true)%>
		</div>
		<div class="cell field">
			<%= Html.TextBox(GetFieldName("CreditUnits"), CreditUnitsValue, new { size = 20, maxlength = 5 })%>
			<%= Html.NBS() %>
			<span class="hint">
				<%= Html.Encode(string.Format(Tr("between {0} and {1} exclusive"), AcademicPlan.CREDITUNITS_MIN_VALUE, 
												AcademicPlan.CREDITUNITS_MAX_VALUE)) %></span>
		</div>
	</div>
	<div class="row">
		<div class="cell label">
			<%= Html.Label(GetFieldName("Terms"), Html.Encode(Tr(Labels.Get("Terms", "AcademicPlan"))))%>
		</div>
		<div class="cell field">
			<%= Html.Hidden(GetFieldName("AddedTerms"), "") %>
			<%= Html.Hidden(GetFieldName("LastTermIndex"), LastAcademicTermIndex)%>
			<%	for (var vIndex = 0; vIndex < AcademicTermNameValues.Count; vIndex++)
			{ %>
				<%= Html.Hidden(GetFieldName("xIndex", "Terms", vIndex), vIndex)%>
				<div class="row <%= ((vIndex > LastAcademicTermIndex) ? "hidden" : "") %>"
						onmouseover="gAcademicPlanFormCtrl.onMouseOverRemovable(event, this)" onmouseout="gAcademicPlanFormCtrl.onMouseOutRemovable(event, this)">
					<div class="cell label top-separator">
						<%= Html.Label(GetFieldName("Name", "Terms", vIndex),
														Html.Encode(Tr(Labels.Get("Name", "AcademicTerm"))), true)%>
					</div>
					<div class="cell field top-separator">
						<%= Html.TextField(GetFieldName("Name", "Terms", vIndex), AcademicTermNameValues[vIndex])%>
					</div>
					<div class="cell top-separator tiny-cell">
						<%= Html.NBS() %>
						<%= HtmlHelperExtensions.Image(Html, Url.Icon("remove.png"), Tr("Remove Term"), new { @class = "link hidden", onclick = "gAcademicPlanFormCtrl.removeTerm(event, this, " + ((vIndex > LastAcademicTermIndex) ? "true" : "false") + ")" })%>
					</div>
				</div>
				<div class="row <%= ((vIndex > LastAcademicTermIndex) ? "hidden" : "") %>"
						onmouseover="gAcademicPlanFormCtrl.onMouseOverRemovable(event, this)" onmouseout="gAcademicPlanFormCtrl.onMouseOutRemovable(event, this)">
					<div class="cell label">
						<%= Html.Label(GetFieldName("OrderNum", "Terms", vIndex),
														Html.Encode(Tr(Labels.Get("OrderNum", "AcademicTerm"))), true)%>
					</div>
					<div class="cell field">
						<%= Html.TextBox(GetFieldName("OrderNum", "Terms", vIndex), AcademicTermOrderNumValues[vIndex], new { size = 20, maxlength = 2 })%>
						<%= Html.Break() %>
						<span class="hint">
									<%= Html.Encode(string.Format(Tr("between {0} and {1} exclusive"), AcademicTerm.ORDERNUM_MIN_VALUE, 
												AcademicTerm.ORDERNUM_MAX_VALUE)) %></span>
					</div>
				</div>
			<% } %>
		</div>
	</div>
	<div class="row add-row">
		<div class="cell label">
			<%= Html.NBS() %>
		</div>
		<div class="cell top-separator">
			<%= Html.PushButton(GetFieldName("addPlanTerm"), Tr("Add Term"), "gAcademicPlanControlCtrl.finishAddTermButton", "")%>
		</div>
	</div>
	<div class="row">
		<div class="cell label">
			<%= Html.Label(GetFieldName("Divisions"),
											Html.Encode(Tr(Labels.Get("Divisions", "AcademicPlan"))))%>
		</div>
		<div class="cell field">
			<%= Html.Hidden(GetFieldName("AddedDivisions"), "") %>
			<%= Html.Hidden(GetFieldName("LastDivisionIndex"), LastCourseDivisionIndex) %>
			<%	for (var vIndex = 0; vIndex < CourseDivisionNameValues.Count; vIndex++)
			{ %>
				<%= Html.Hidden(GetFieldName("xIndex", "Divisions", vIndex), vIndex)%>
				<div class="row <%= ((vIndex > LastCourseDivisionIndex) ? "hidden" : "") %>"
						onmouseover="gAcademicPlanFormCtrl.onMouseOverRemovable(event, this)" onmouseout="gAcademicPlanFormCtrl.onMouseOutRemovable(event, this)">
					<div class="cell label top-separator">
						<%= Html.Label(GetFieldName("Name", "Divisions", vIndex),
														Html.Encode(Tr(Labels.Get("Name", "CourseDivision"))), true)%>
					</div>
					<div class="cell field top-separator">
						<%= Html.TextField(GetFieldName("Name", "Divisions", vIndex), CourseDivisionNameValues[vIndex])%>
					</div>
					<div class="cell top-separator tiny-cell">
						<%= Html.NBS() %>
						<%= HtmlHelperExtensions.Image(Html, Url.Icon("remove.png"), Tr("Remove Division"), new { @class = "link hidden", onclick = "gAcademicPlanFormCtrl.removeDivision(event, this, " + ((vIndex > LastCourseDivisionIndex) ? "true" : "false") + ")" })%>
					</div>
				</div>
				<div class="row <%= ((vIndex > LastCourseDivisionIndex) ? "hidden" : "") %>">
					<div class="cell label">
						<%= Html.Label(GetFieldName("Categories", "Divisions", vIndex),
														Html.Encode(Tr(Labels.Get("Categories", "CourseDivision"))))%>
					</div>
					<div class="cell field">
						<%= Html.Hidden(GetFieldName("AddedCategories", "Divisions", vIndex), "")%>
						<%= Html.Hidden(GetFieldName("LastCategoryIndex", "Divisions", vIndex), LastCourseDivisionCategoryIndex[vIndex])%>
						<% for (var vIndex2 = 0; vIndex2 < CourseDivisionCategoryNameValues[vIndex].Count; vIndex2++)
						{ %>
							<% var vParentName2 = GetFieldName("Categories", "Divisions", vIndex); %>
							<%= Html.Hidden(GetFieldName("xIndex", vParentName2, vIndex2), vIndex2)%>
							<div class="row <%= ((vIndex2 > LastCourseDivisionCategoryIndex[vIndex]) ? "hidden" : "") %>"
									onmouseover="gAcademicPlanFormCtrl.onMouseOverRemovable(event, this)" onmouseout="gAcademicPlanFormCtrl.onMouseOutRemovable(event, this)">
								<div class="cell label top-separator">
									<%= Html.Label(GetFieldName("Name", vParentName2, vIndex2),
																	Html.Encode(Tr(Labels.Get("Name", "CourseCategory"))), true)%>
								</div>
								<div class="cell field top-separator">
									<%= Html.TextField(GetFieldName("Name", vParentName2, vIndex2), CourseDivisionCategoryNameValues[vIndex][vIndex2])%>
								</div>
								<div class="cell top-separator tiny-cell">
									<%= HtmlHelperExtensions.Image(Html, Url.Icon("remove.png"), Tr("Remove Category"), new { @class = "link hidden", onclick = "gAcademicPlanFormCtrl.removeCategory(event, this, " + ((vIndex2 > LastCourseDivisionCategoryIndex[vIndex]) ? "true" : "false") + ")" })%>
								</div>
							</div>
							<div class="row <%= ((vIndex2 > LastCourseDivisionCategoryIndex[vIndex]) ? "hidden" : "") %>"
									onmouseover="gAcademicPlanFormCtrl.onMouseOverRemovable(event, this)" onmouseout="gAcademicPlanFormCtrl.onMouseOutRemovable(event, this)">
								<div class="cell label">
									<%= Html.Label(GetFieldName("Code", vParentName2, vIndex2),
																	Html.Encode(Tr(Labels.Get("Code", "CourseCategory"))))%>
								</div>
								<div class="cell field">
									<%= Html.TextBox(GetFieldName("Code", vParentName2, vIndex2), CourseDivisionCategoryCodeValues[vIndex][vIndex2], new { size = 20, maxlength = 5 })%>
									<%= Html.Break() %>
									<span class="hint">
									<%= Html.Encode(string.Format(Tr("maximum of {0} characters"), CourseCategory.CODE_MAX_LENGTH)) %></span>
								</div>
							</div>
						<% } %>
					</div>
				</div>
				<div class="row add-row <%= ((vIndex > LastCourseDivisionIndex) ? "hidden" : "") %>">
					<div class="cell label">
						<%= Html.NBS() %>
					</div>
					<div class="cell top-separator">
						<%= Html.PushButton(GetFieldName("addPlanDivisionCategory", "Divisions", vIndex), Tr("Add Category"), "gAcademicPlanControlCtrl.finishAddCategoryButton", "")%>
					</div>
				</div>
			<% } %>
		</div>
	</div>
	<div class="row add-row">
		<div class="cell label">
			<%= Html.NBS() %>
		</div>
		<div class="cell top-separator">
			<%= Html.PushButton(GetFieldName("addPlanDivision"), Tr("Add Division"), "gAcademicPlanControlCtrl.finishAddDivisionButton", "")%>
		</div>
	</div>
</div>
<script type="text/javascript">
	gDomReadyQueue.push('gAcademicPlanFormCtrl.removalConfirmationMessage = "<%= SecurityHelper.Escape(Tr("Are you sure? You still need to Save for the changes to take effect.\\nDependants will also be deleted!")) %>";');
</script>
	

<% if (!Model.IsSub)
   { %>
		<div class="rows-wrapper action">
			<div class="row">
				<div class="cell label">
					&nbsp;
				</div>
				<div class="cell">
					<%= Html.SubmitButton("submitForm", Html.Encode(SubmitButtonValue), "")%>
					<% if (Model.IncludeCancelButton)
					{ %>
						<%= Html.NBS() %>
						<%= Html.CancelButton("cancelForm", Html.Encode(Tr("Cancel")), "")%>
					<% } %>
				</div>
			</div>
		</div>
<% } %>


<% if (!string.IsNullOrEmpty(Title))
   { %>
		</fieldset>
<% } %>


<% if (!Model.IsSub)
   { %>
		<% End(); %>
		</div>
<% } %>